#!/usr/bin/env python3
"""
自动化部署脚本
"""

import os
import sys
import argparse
from build_nuitka import NuitkaBuilder, debug_print


def main():
    parser = argparse.ArgumentParser(description="液冷机控制软件部署工具")
    parser.add_argument("--platform", choices=["win", "linux", "mac", "all"], 
                       default="current", help="目标平台")
    parser.add_argument("--clean", action="store_true", help="清理构建文件")
    parser.add_argument("--package", action="store_true", help="创建分发包")
    parser.add_argument("--install-deps", action="store_true", help="安装依赖")
    
    args = parser.parse_args()
    
    # 安装依赖
    if args.install_deps:
        debug_print("安装依赖...")
        os.system(f"{sys.executable} -m pip install -r requirements.txt")
        os.system(f"{sys.executable} -m pip install nuitka")
    
    # 清理
    if args.clean:
        builder = NuitkaBuilder()
        builder.clean_previous_builds()
        debug_print("清理完成")
    
    # 构建
    if args.platform != "clean":
        builder = NuitkaBuilder()
        builder.build()
    
    debug_print("部署完成!")


if __name__ == "__main__":
    main()